/**
 * @description 数组格式化, 每三位以逗号分隔
 * @date 2024-10-16
 * @author hedongliang
 * @param num
 * @returns {string}
 */
export const formatNumber = (num: number) => {
  let newNum = num.toString();
  const pattern = /(-?\d+)(\d{3})/;
  while (pattern.test(newNum)) {
    newNum = newNum.replace(pattern, "$1,$2");
  }
  return newNum;
};
